//
//  PSSql.m
//  PSExtensions
//
//  Created by PoiSon on 15/10/22.
//  Copyright © 2015年 yerl. All rights reserved.
//

#import "PSDicRecord_private.h"

@implementation PSSql
+ (instancetype)buildSql:(NSString *)sql, ...{
    return [self buildSql:sql withArgs:va_array(sql)];
}

+ (instancetype)buildSql:(NSString *)sql withArgs:(NSArray<id> *)args{
    PSSql *instance = [[self alloc] init];
    instance.sql = sql;
    instance.args = args;
    return instance;
}

- (NSString *)description{
    return format(@"<PSSql %p>:{ sql: \"%@\", args: ...<%@ objects>}", self, self.sql, @(self.args.count));
}

- (NSString *)debugDescription{
    NSMutableString *args = [NSMutableString string];
    if (self.args.count > 0) {
        [[[args ps_appendString:@"("] ps_appendString:[self.args ps_join:@", "]] ps_appendString:@")"];
    }else{
        [args appendString:@"<0 objects>"];
    }
    return format(@"<PSSql %p>:\n{\n   sql: \"%@\",\n   args: %@\n}", self, self.sql, args);
}
@end
